<%@ page language="java" contentType="text/html;" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<!DOCTYPE html>
<html>
<head>
<jsp:include page="../inc_jqgrid.jsp"></jsp:include>
<title>订单查询-查看详情</title>
<style>
	 .divBox .white{
		background:white;
		height:10px;
		text-align:center;
	} 
</style>
<link rel="stylesheet" type="text/css" href="${ctx}/css/skBook.css"/>
<link rel="stylesheet" type="text/css" href="${ctx}/css/orderDetail.css"/>
<script type="text/javascript">
$(function(){
	layer.load();
	$.ajax({
		type:'get',
		url:'${ctx}/order/orderDetail/${orderNumber}',
		dataType:'json',
		success:function(data){
            layer.closeAll();
			if(data.success){
				//alert(data.obj.toStartAirport);
				initPage(data.obj);
			}
			else{
				layer.alert(data.msg);
			}
		},
		error:function(msg){
            layer.closeAll();
			layer.alert("请检查您的网络连接，然后重试！");
		}
	});
    //加载旅客信息
    $("#jqGrid").jqGrid({
        url:'${ctx}/order/queryPassenger/${orderNumber}?temp='+Math.random(),
        mtype: "GET",
        datatype: "json",
        shrinkToFit: true,//按比例初始化列宽度
        viewrecords: true,//是否要显示总记录数
        rownumbers: true,//显示行顺序号
        rownumWidth: 35,//顺序号宽度
        //multiselect: true,//定义是否可以多选
        //multiboxonly: true,//为ture时只有选择checkbox才会起作用
        height : '100%', //"100%"
        rowNum: 500,//每页行数
        rowList : [ 500 ],//调整表格显示的记录数
        width: 1300,
        caption: "",//标题
        colModel: [
            { label: 'Id', name: 'id', key: true, width: 75,hidden:true  },
            { label: '旅客姓名', name: 'Customer1', width: 70,
                formatter : function(value,ops,row){
                    var lastNameEn=row.lastName_en;
                    var firstNameEn=row.firstName_en;
                    return "<span>"+lastNameEn+"</span>"+"<span>"+firstNameEn+"</span>"
                } },
            { label: '中文姓名', name: 'Customer2', width: 70,
                formatter : function(value,ops,row){
                    var lastNamecn=row.lastName_cn;
                    var firstNamecn=row.firstName_cn;
                    return "<span>"+lastNamecn+"</span>"+"<span>"+firstNamecn+"</span>"
                }},
            { label: '性别', name: 'sex1', width: 40,
                formatter : function(value,ops,row){
                    if(row.sex ==2){
                        return "女";
                    }else if(row.sex==1){
                        return "男";
                    };
                }},
            { label:'旅客类型', name: 'passageType1', width: 70,
                formatter : function(value,ops,row){
                    if(row.passageType ==0){
                        return "婴儿";
                    }else if(row.passageType==1){
                        return "成人";
                    }else if(row.passageType == 2){
                        return "儿童";
                    };
                }},
            { label:'证件类别', name: 'docType1', width: 70,
                formatter : function(value,ops,row){
                    if(row.docType==1){
                        return "身份证 ";
                    }else if(row.docType == 2){
                        return "护照";
                    };
                }},
            { label:'证件号', name: 'docId', width: 100 },
            { label:'证件有效期', name: 'docExpireDate', width: 80 },
            { label:'出生日期', name: 'birthDate', width: 80 },
            { label:'手机号', name: 'mobile', width: 100 },
            { label:'国籍', name: 'nationality', width: 80 },
            { label:'签发国家', name: 'issueCountry', width: 80 },
            { label:'酒店', name: 'grogshop', width: 100 },
            { label:'联运', name: 'throughTraffic', width: 100 },
            { label:'备注', name: 'remark', width: 100 }
        ]
    });
});
var purchQuantity = 0;
//加载航班信息表格
function initPage(b){
	$("#itineraryName").text(b.toStartAirport+"-"+b.toEndAirport);
	$("#periodDesc").text(b.travelDays);
	$("#payPrice").html(b.payPrice);
	//$("#orderStatus").html(b.orderStatus);
	$("#orderStatus").html(CommonConverter.toOrderBizStatusStr(b.orderStatus));
	$("#unitPrice").html(b.unitPrice);
	$("#purchQuantity").html(b.purchQuantity);
	$("#payEndTime").html(b.payEndTime);
	$("#ticketEndTime").html(b.ticketEndTime);
	$("#pssOrderNumber").html(b.pssOrderNumber);
	$("#bizStatus").html(CommonConverter.toOrderBizStatusStr(b.orderStatus));
	$("#payStatus").html(CommonConverter.toOrderPayStatusStr(b.financeStatus));
	purchQuantity = b.purchQuantity;
	for(var n in b.flights){
		var f = b.flights[n];
		var seatClass = CommonConverter.toFlightCabinTypeStr(f.cabin); 

        var temp = "";
        if(n==0){
            temp = "<td rowspan='2'><input type='text' id='price' style='border:none;text-align:center;' readonly='readonly' value='"+CommonConverter.formatMoney(b.unitPrice)+"'/></td>";
            temp += "<td rowspan='2'>"+b.purchQuantity+"</td>";
        }
        var i = n-0+1;
        $("#tbl_flights").append("<tr class='table_body'>"
                +"<td>"+i+"</td>"
                +"<td>"+f.flightNumber+"</td>"
                +"<td>"+seatClass+"</td>"
                +"<td>"+f.departureCity+"("+f.departureCode+")"+"-"+f.arrivalCity+"("+f.arrivalCode+")"+"</td>"
                +"<td>"+f.departureDateStr+"</td>"
                +"<td>"+f.departureTime+"</td>"
                +"<td>"+f.arrivalTime + (f.intervalDay>=0?("(+"+f.intervalDay+")"):"")+"</td>"
                +temp
                +"</tr>");
	}
};
</script>
</head>
<body>
<jsp:include page="../head.jsp"></jsp:include>
	<div class="divBox" style="border-top:1px solid #f1f1f1">
			<div class="cHeader white">
				平台订单号：<span id="orderNumber">${orderNumber}</span>&nbsp;&nbsp;&nbsp;&nbsp;
				PSS订单号：<span id="pssOrderNumber"></span>&nbsp;&nbsp;&nbsp;&nbsp;
				业务状态：<span id="bizStatus"></span>&nbsp;&nbsp;&nbsp;&nbsp;
				财务状态：<span id="payStatus"></span>
			</div> 
			<!--航班信息-->
			<div class="cHeader">
				<img src="${ctx }/image/book/green.gif"/><span>航班信息</span>
			</div>
			<div class="cContent">
				<div class="ccHeader">
					<span id="itineraryName">机场-机场</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;往返间隔天数  ：<span id="periodDesc"></span>
				</div>
				<table class="tableInf" border="1">
					<thead>
						<tr>
							<td style="width:51px">序号</td>
							<td style="width:105px">航班号</td>
							<td style="width:105px">舱位</td>
							<td style="width:480px">行程</td>
							<td style="width:103px">起飞日期</td>
							<td style="width:103px">出发时刻</td>
							<td style="width:103px">到达时刻</td>
							<td style="width:123px">单价含税（CNY/张）</td>
							<td style="width:84px">采购数量</td>
						</tr>
					</thead>
					<tbody id="tbl_flights">
					</tbody>
				</table>
				<!--旅客信息-->
				<div class="cHeader" style="padding-top:20px;">
					<img src="${ctx }/image/book/green.gif"/><span>价格及支付信息</span>
				</div>
				<table class="tableInf" border="1" style="margin-top:20px;">
					<thead>
						<tr>
							<td width="248">支付金额</td>
							<td width="248">支付截止时间</td>
							<td width="248">类型</td>
							<td width="248">状态</td>
							<td width="248">最晚出票时间</td>
						</tr>
					</thead>
					<tbody>
						<tr>
                            <td><span id="payPrice"></span></td>
                            <td><span id="payEndTime"></span></td>
                            <td>票款</td>
                            <td><span id="orderStatus"></span></td>
							<td width="248"><span id="ticketEndTime"></span></td>
						</tr>
					</tbody>
				</table>
				<!--旅客信息-->
				<div class="cHeader" style="padding-top:20px;">
					<img src="${ctx }/image/book/green.gif"/><span>旅客信息</span>
				</div>
                <table id="jqGrid"></table>
			</div>
		</div>

 <jsp:include page="../footer.jsp"></jsp:include>
</body>
</html>